Skip to content

Document Battle Castle App setup functions#941

Merged
ravepossum merged 2 commits intopret:mainfrom
VicSevenT:battle_castle_app_2
Feb 16, 2026
Merged

Document Battle Castle App setup functions#941
ravepossum merged 2 commits intopret:mainfrom
VicSevenT:battle_castle_app_2

Conversation

@VicSevenT
Copy link
Contributor

Continuing off of #923, this PR focuses mainly on the functions in each app that handle setting up the graphics and a few other initializations. A lot of this is boilerplate that is very similar to the Battle Hall app (#911), not getting into the app's core logic yet.

The biggest item of note here I think is the naming of the two apps as BattleCastleSelfApp and BattleCastleOpponentApp. I chose these names based off the list items that open each of them when in between rounds: "SELF" and "OPPONENT". The first allows the player to view and modify their own lineup, the latter to view and modify the upcoming opponent.

Copy link
Collaborator

@ravepossum ravepossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I do think Self is more awkward than Player, but I also think it makes sense to match the terminology the game actually uses. I could probably be convinced either way, but Self seems fine to me.

@@ -31,7 +31,7 @@ u8 ov104_0223B7DC(u8 param0, BOOL param1);
FieldBattleDTO *ov104_0223B810(UnkStruct_ov104_0223BA10 *param0, UnkStruct_ov104_02230BE4 *param1);
static u32 ov104_0223B9E4(u8 param0);
u8 ov104_0223BA10(UnkStruct_ov104_0223BA10 *param0);
BOOL ov104_0223BA14(u8 param0);
BOOL BattleCastle_IsMultiPlayerChallenge(u8 param0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: We can remove this unnecessary declaration.

FieldBattleDTO *ov104_0223B810(UnkStruct_ov104_0223BA10 *param0, UnkStruct_ov104_02230BE4 *param1);
u8 ov104_0223BA10(UnkStruct_ov104_0223BA10 *param0);
BOOL ov104_0223BA14(u8 param0);
BOOL BattleCastle_IsMultiPlayerChallenge(u8 param0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: param0 -> challengeType

}

return 0;
return challengeType == 2 || challengeType == 3;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: If we know these indicate multiplayer challenges, can we document the constants at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am planning on documenting these, but I'd like to leave that out of this PR for now. I've been waiting because I wasn't sure what "3" corresponded to ("2" is for multi-battles as initiated from inside the Battle Castle). I now am reasonably sure that "3" is for multi-battle started through the Wi-fi club, but want to handle this separately in a dedicated PR as I think the Battle Hall, and probably all the non-Tower facilities use the same values.

@@ -9,7 +9,7 @@

#define BASE_TILE_WINDOW_FRAME (1024 - STANDARD_WINDOW_TILE_COUNT)

static const WindowTemplate Unk_ov107_0224A288[] = {
static const WindowTemplate sSelfAppWinTemplates[] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Can you format these templates like (for example) sStaticWindowTemplates in src/applications/pokemon_summary_screen/window.c?
Here's a quick and dirty regex I wrote for replacing these if that would help:
Match:
(\s+){\s+(\w+), (\w+), (\w+), (\w+), (\w+), (\w+), (\w+) }
Substitution:
$1{\n$1 .bgLayer = $2,\n$1 .tilemapLeft = $3,\n$1 .tilemapTop = $4,\n$1 .width = $5,\n$1 .height = $6,\n$1 .palette = $7,\n$1 .baseTile = $8,\n$1}
Getting constants for the window IDs like the summary screen windows at some point would be nice as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformatted. And I am planning to add window constants in the next PR.

{
const WindowTemplate *v1 = sWinTemplates[param2].templates;
u32 numTemplates = sWinTemplates[param2].numTemplates;
const WindowTemplate *v1 = sWinTemplates[isOpponentApp].templates;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: template or something for v1 seems appropriate here.

{
UnkStruct_ov107_02246170 *v0 = ApplicationManager_Data(appMan);
BattleCastleOpponentApp *v0 = ApplicationManager_Data(appMan);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: app seems sufficient, like in the Init func and Exit funcs

}
break;
case 4:
if (ov107_02246D3C(v0) == 1) {
if (State_FadeOutApp(v0) == 1) {
return 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: TRUE. Similar for the FALSE in the return statement below.


param0->unk_3E8 = BattleCastleAppSprite_New(&param0->unk_1D8, 0, 0, 0, 4, 160, 10, 0, NULL);
param0->unk_3EC = BattleCastleAppSprite_New(&param0->unk_1D8, 0, 0, 0, 5, 160, 124, 0, NULL);
app->upArrowSprite = BattleCastleAppSprite_New(&app->spriteMan, 0, 0, 0, 4, 160, 10, 0, NULL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Not blocking for this PR, but it would be good to get constants for the different assets' resource IDs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also looking at creating constants for the animation IDs in a future PR.

lhearachel
lhearachel previously approved these changes Feb 15, 2026
@lhearachel lhearachel dismissed their stale review February 15, 2026 19:05

Ravepossum already claiming

@ravepossum ravepossum self-assigned this Feb 15, 2026
@ravepossum ravepossum merged commit f682c3e into pret:main Feb 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants